<?php echo $this->Html->script(array('ckeditor/ckeditor','ckeditor/adapters/jquery','admin/multiSelect'));?>
<script type="text/javascript">
jQuery(function(){
	var config = {
			toolbar:[
						['Source','Find','Replace', '-','Undo','Redo'],['UIColor'],['sj56image'],
						['Bold', 'Italic','Underline','Strike','Subscript','Superscript' ],
						['Link','Unlink','Anchor' ],
					    [ 'NumberedList','BulletedList','-','Outdent','Indent','-','Blockquote','CreateDiv',
					    '-','JustifyLeft','JustifyCenter','JustifyRight','JustifyBlock'], '/',
						[ 'Styles','Format','Font','FontSize' ], ['TextColor','BGColor'],
						[ 'Maximize']
					],
			height:450
		};
	jQuery('.textarea textarea').ckeditor(config);
	 $( "#TicketDateStart" ).datepicker({
        defaultDate: '',
        changeMonth: true,
        numberOfMonths: 1,
        dateFormat:'yy-mm-dd',
        onClose: function( selectedDate ) {
            $( "#TicketDateEnd" ).datepicker( "option", "minDate", selectedDate );
        }
    });
    $( "#TicketDateEnd" ).datepicker({
        defaultDate: '',
        changeMonth: true,
        numberOfMonths: 1,
        dateFormat:'yy-mm-dd',
        onClose: function( selectedDate ) {
            $( "#TicketDateStart" ).datepicker( "option", "maxDate", selectedDate );
        }
    });
    $( "#TicketShowtime" ).datepicker({
        defaultDate: '',
        changeMonth: true,
        numberOfMonths: 1,
        dateFormat:'yy-mm-dd'
    });
    $( "#TicketEndtime" ).datepicker({
        defaultDate: '',
        changeMonth: true,
        numberOfMonths: 1,
        dateFormat:'yy-mm-dd'
    });
});
//图片选择callback
uploadPicCallbackView = function(data){
	jQuery('#ticket_view_preview').attr('src',GM.RootScript+'/img/'+data.pic_link+'.100x100.'+data.ext);
	jQuery('#TicketViewPhotoId').val(data.pic_id);
};
//图片选择callback
uploadPicCallbackList = function(data){
	jQuery('#ticket_list_preview').attr('src',GM.RootScript+'/img/'+data.pic_link+'.100x100.'+data.ext);
	jQuery('#TicketListPhotoId').val(data.pic_id);
};
</script>
<h1><?php echo $this->Html->image('bootstrap/posts.png')?>添加票品</h1>
<div class="bloc">
	<div class="title">
		<?php echo $this->element('admin/bread')?>
	</div>
    <div class="content">
	<?php echo $this->Form->create('Ticket'); ?>
	<table style = 'width:100%'>
		<tr>
			<td width = "50%">
				<?php 
					echo $this->Form->input('sys_website_id',array('label'=>'所属站点','style'=>'z-index: -1;','options'=>$SysWebsite,'default'=>$this->Session->read('SITEID')));
				?>
			</td>
			<td width = "50%" class='double_select'>
				<?php 
				$scate = $this->Form->input('ticket_scate_id',array('label'=>false,'div'=>false,'id'=>'s_cate'));
				echo $this->Form->input('ticket_cate_id',array('label'=>'票品分类','after'=>$scate,'id'=>'f_cate')); 
				?>
			</td>
		</tr>
		<tr>
			<td width = "50%" class = 'ticket_title'>
				<?php 
				$corner = $this->Form->input('ticket_corner',array('label'=>false,'div'=>false,'options'=>$ticketconner));
				echo $this->Form->input('title',array('label'=>'票品名称','after'=>$corner));
				?>
			</td>
			<td width = "50%">
				<?php echo $this->Form->input('venue_id',array('label'=>'所在场馆'));?>
			</td>
		</tr>
		<tr>
			<td colspan = 2>
				<?php echo $this->element('SeoMeta.seometa');?>
				<br/>
			</td>
		</tr>
		<tr>
			<td width = "50%">
				<label>列表预览图</label>
				<?php 
					echo $this->Form->input('list_photo_id',array('type'=>'hidden'));
					if (isset($this->request->data['ListPhoto']['id']) && $this->request->data['ListPhoto']['id']>0){
						$imgsrc = thumb($this->request->data['ListPhoto']);
					}else{
						$imgsrc = 'Album.nopic.jpg';
					}
					echo $this->Html->image($imgsrc,array('style'=>'float:left','id'=>'ticket_list_preview'));
					echo $this->element('Album.ajaxUploadForm',array('upload'=>true,'list'=>true,'album_id'=>2,'userCallback'=>'uploadPicCallbackList'));
				?>
				<br/>
			</td>
			<td width = "50%">
				<?php
				?>
				<label>详情预览图</label>
				<?php 
					echo $this->Form->input('view_photo_id',array('type'=>'hidden'));
					if (isset($this->request->data['ViewPhoto']['id']) && $this->request->data['ViewPhoto']['id']>0){
						$imgsrc = thumb($this->request->data['ViewPhoto']);
					}else{
						$imgsrc = 'Album.nopic.jpg';
					}
					echo $this->Html->image($imgsrc,array('style'=>'float:left','id'=>'ticket_view_preview'));
					echo $this->element('Album.ajaxUploadForm',array('upload'=>true,'list'=>true,'album_id'=>2,'userCallback'=>'uploadPicCallbackView'));
				?>
				<br/>
			</td>
		</tr>
		<tr>
			<td width = "50%">
				<?php echo $this->Form->input('date_start',array('label'=>'上架日期','type'=>'text','class'=>'datepicker'));?>
			</td>
			<td width = "50%">
				<?php echo $this->Form->input('date_end',array('label'=>'下架日期','type'=>'text','class'=>'datepicker'));?>
			</td>
		</tr>
		<tr>
			<td width = "50%">
				<?php echo $this->Form->input('showtime',array('label'=>'上演日期','type'=>'text','class'=>'datepicker','default'=>date('Y-m-d')));?>
			</td>
			<td width = "50%">
				<?php echo $this->Form->input('endtime',array('label'=>'结束日期','type'=>'text','class'=>'datepicker'));?>
			</td>
		</tr>
		<tr>
			<td colspan = 2>
				<?php echo $this->Form->input('content',array('label'=>'票品内容'));?>
			</td>
		</tr>
		<tr>
			<td colspan = 2>
			<?php
			echo $this->Form->input('tags',array('default'=>'','label'=>'Tag(多个标签请用英文逗号","分隔)','style'=>'width:90%'));
				echo $this->Form->input('price_max',array('type'=>'hidden','default'=>0));
				echo $this->Form->input('price_min',array('type'=>'hidden','default'=>0));
				echo $this->Form->input('count',array('type'=>'hidden','default'=>0));
				echo $this->Form->input('sort',array('label'=>'排序','default'=>100));
				echo $this->Form->input('spt_eticket',array('label'=>'电子票','type'=>'checkbox'));
				echo $this->Form->input('spt_seat',array('label'=>'在线选座','type'=>'checkbox'));
				echo $this->Form->input('sort_top',array('label' => '置顶','type'=>'checkbox'));
			?>
			<?php echo $this->Form->submit(__('Submit')); ?>
			</td>
		</tr>
	</table>
		<?php echo $this->Form->end(); ?>
	</div>
</div>
<div style = 'display:none'>
<?php 	echo $this->element('Album.ajaxUploadForm',array('pluginid'=>'sj56image','upload'=>true,'list'=>true,'album_id'=>2,'userCallback'=>'editorPluginCallback'));?>
</div>
<style>
.double_select .selector{
	float:left;
}			
#TicketTitle,.ticket_title .selector{
	float:left;
}
#TicketAdminAddForm #uniform-TicketTicketCorner select,
#TicketAdminAddForm #uniform-TicketTicketCorner span,
#TicketAdminAddForm #uniform-TicketTicketCorner{
	width:100px !important;
}
#TicketAdminAddForm #uniform-TicketTicketCorner{
	margin-left:10px;
}
</style>
<script>
$(function(){
	var action = GM.rootUrl+'admin/TicketCates/option';
	ms.ready(2,action);
});
</script>